<template>
	<div>
		<!-- <view style="background-color: #ffffff;margin: 10px;border-radius: 12px;padding: 15px;">
			
		</view> -->
		<uni-list>
			<uni-list-item title="客户名称" :rightText="formData.customerName" />
			<uni-list-item title="客户类型" :rightText="customerEntType_[formData.customerEntType]" />
			<uni-list-item title="客户性质" :rightText="customerEntNature_[formData.customerEntNature]" />
			<uni-list-item title="所属行业" :rightText="customerIndustry_[formData.customerIndustry]" />
			<uni-list-item title="企业信用代码" :rightText="formData.customerCode" />
			<uni-list-item title="办公电话" :rightText="formData.customerTel" />
			<uni-list-item title="邮政编码" :rightText="formData.postcode" />
			<uni-list-item title="创建时间" :rightText="formData.createTime" />
			<uni-list-item title="经营地址" :rightText="formData.customerDistrictName+''+formData.customerAddress" />
			<uni-list-item title="联系人" :rightText="formData.leader" />
			<uni-list-item title="职务" :rightText="formData.customerPost" />
			<uni-list-item title="联系电话" :rightText="formData.phone" />
			<uni-list-item title="电子邮箱" :rightText="formData.email" />
			<uni-list-item>
				<template v-slot:body>
					<text style="font-size: 14px;color: #3b4144;overflow: hidden;width: 90px;">相关附件</text>
				</template>
				<template v-slot:footer>
					<div style="flex: 1;">
						<myfilepicker readonly :fileIdString="formData.otherInfo" :fileMediatype="'all'"></myfilepicker>
					</div>
				</template>
			</uni-list-item>
			<uni-list-item title="备注" :rightText="formData.remark" />
		</uni-list>
		<view style="height: 20px;"></view>
		<view v-if="whatAddress.length>0" style="position: relative;display: flex;flex-direction: row;align-items: center;padding: 12px 10px;font-weight: 400;">
			<view style="width: 4px;height: 12px;border-radius: 10px;background-color: #2979ff;margin-right: 6px"></view>
			<view style="display: flex;flex-direction: column;flex: 1;color: #333;">地址簿</view>
		</view>
		<!-- <template v-if="whatAddress.length>0"><uni-tag style="margin-left: 15px;" :inverted="true" text="地址簿" type="primary" /></template> -->
		<view v-for="(item,index) in whatAddress" :key="index">
			<uni-card :title="item.contactName"  :extra="item.phone">
				<text>{{item.bookDistrictName}}{{item.bookAddress}}</text>
			</uni-card>
		</view>
		<view style="height: 50px;"></view>
	</div>
</template>

<script>
	import {getCustomerDetails} from '@/api/system/customer.js'
	import {getDicts} from '@/api/system/dict.js'
	import myfilepicker from '@/components/uploadFile/uploadFile.vue'
	
	export default {
		components: {
			myfilepicker
		},
		data() {
			return {
				formData:{}, //详情
				//下拉框 ->客户类型
				customerEntType_: [],
				//下拉框 ->客户性质
				customerEntNature_: [],
				//下拉框 ->所属行业
				customerIndustry_: [],
				// 地址源
				whatAddress: [],
				customerId:'',
			}
		},
		onLoad(e) {
			//根据客户id查询客户详情
			if(e.customerId)
			{
				this.customerId=e.customerId
				uni.showLoading({
					title: '正在加载',
				})
				//获取客户详情
				getCustomerDetails(e.customerId).then(res => {
					uni.hideLoading()
					if(res.code=='200')
					{
						this.formData=res.data
						this.formData.customerDistrict=this.formData.customerDistrict.toString()
						this.whatAddress=res.data.bookList||[]
					}
					else
					{
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			}
		},
		created() {
			//获取客户类型
			getDicts('customer_type').then(res=>{
				res.data.forEach(item=>{
					this.customerEntType_[item.dictValue]=item.dictLabel
				})
			})
			//获取客户性质
			getDicts('customer_nature').then(res=>{
				res.data.forEach(item=>{
					this.customerEntNature_[item.dictValue]=item.dictLabel
				})
			})
			//获取所属行业
			getDicts('industry_type').then(res=>{
				res.data.forEach(item=>{
					this.customerIndustry_[item.dictValue]=item.dictLabel
				})
			})
		},
		methods: {
			
		},
	}
</script>

<style scoped>
::v-deep .uni-list-item__extra{
	flex: 1;
}
</style>